<!-- 地址选择、编辑、新增组件 -->
<template>
  <div id="yz_addressList">
    <!-- 当前账号地址记录 s-->
    <van-popup v-model="showAddress" :get-container="goodsStyle?'':'#appMain'" @closed="closedAddress" :close-on-click-overlay="false" class="pop-base-class" position="bottom" round style="background-color: #F5F5F5;" closeable>
      <div class="pop-base-title">选择地址</div>
      <div class="pop-base-content" >
        <div v-if="!fun.isTextEmpty(addressData)">
          <div class="box-base flex-a-c" v-for="item in addressData" :key="item.id">
            <div style="flex: 1;" @click.stop="selectAddress(item)">
              <div class="flex-a-c f-15">{{ item.username }} {{ item.mobile }}
                <van-tag v-if="item.isdefault === 1" type="primary" color="var(--themeBaseColor)" class="margin-left-6">{{ $i18n.t('base.default') }}</van-tag>
              </div>
              <div class="flex-a-c f-16 f-bold" style="line-height: 1.125rem;margin-top: 5px;">{{ item.province }} {{ item.city }} {{ item.district }} {{ item.street || "" }} {{ item.address }}</div>
            </div>
            <van-icon name="edit" @click.stop="editAddress(item)" v-if="item.is_plugin != 1" class="margin-left-12" size="24"/>
          </div>
          <span @click="getAddress" style="line-height: 2rem;color: #666;" v-if="finished">点击加载更多</span>
        </div>
        <div v-else-if="this.$store.state.isloadding" style="color: #666666;">正在加载数据...</div>
        <div v-else style="color: #666666;" >{{ $i18n.t('base.noAddressRecord') }}！</div>
      </div>
      <div class="pop-base-bottom flex" @click="addAddress" v-if="add_address">
        <van-button round type="danger" block color="var(--themeBaseColor)" style="height: 40px;">{{ $i18n.t('base.addAddress') }}</van-button>
      </div>
    </van-popup>
    <!-- 当前账号地址记录 end-->
    <template v-if="codeEdit">
      <div class="m-dialog">
        <div>
          <van-field v-model="form.country_code" type="number" required :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.countryCode')" :label="$i18n.t('base.countryCode') + '：'" v-if="country_code" :border='false' style="font-size: 1rem;" label-width='3.5em'/>
          <div class="address_a">
            <ul>
              <li>
                <span style="white-space: nowrap;">{{$i18n.t('base.recipient')}}：</span>
                <input type="text" v-model="form.username" maxlength="20" :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.recipient')" />
              </li>
              <li>
                <span style="white-space: nowrap;">{{$i18n.t('base.contactNumber')}}：</span>
                <input type="tel" v-model="form.mobile" :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.contactNumber')" />
              </li>
            </ul>
          </div>
          <p style="background: #eee;text-align: left;padding: 0 0.4375rem;font-weight: bold;line-height: 2rem;">以上内容可修改</p>
          <template v-if="model.is_plugin == 1">
            <van-cell-group :border="false" class="set-address">
              <van-cell :border="false" center>
                <span slot="title">设置默认地址：</span>
                <van-switch slot="default" :disabled='true' v-model="form.isDefault" active-color="#f15353" inactive-color="#fff" size="25px" />
              </van-cell>
            </van-cell-group>

            <van-cell-group :border="false" class="set-address" >
              <van-cell :border="false" center v-if="!region_hide" >
                <span slot="title">所在地区：</span>
                <input slot="default" type="text" v-model="addressName" readonly placeholder="请选择收货地址" onfocus="blur();" />
              </van-cell>

              <van-cell :border="false" center v-if="strShow && !region_hide" >
                <span slot="title">街道：</span>
                <input slot="default" type="text" v-model="form.street" readonly placeholder="请选择街道" onfocus="blur();" />
              </van-cell>
              <van-cell :border="false" center v-for="(item,index) in model.plugin_data" :key="index">
                <span slot="title">{{item.name}}：</span>
                <input style="text-align: right;" slot="default" disabled="true" type="text" v-model="item.value" readonly placeholder="" onfocus="blur();" />
              </van-cell>
            </van-cell-group>

          </template>
          <template v-else >
            <van-cell-group :border="false" class="set-address">
              <van-cell :border="false" center>
                <span slot="title">设置默认地址：</span>
                <van-switch slot="default" :disabled='disableDefault' v-model="form.isDefault" active-color="#f15353" inactive-color="#fff" size="25px" />
              </van-cell>
            </van-cell-group>

            <van-cell-group :border="false" class="set-address" v-if="!region_hide">
              <van-cell :border="false" center is-link>
                <span slot="title">所在地区：</span>
                <input slot="default" type="text" @click.stop="openAddress" v-model="addressName" readonly placeholder="请选择收货地址" onfocus="blur();" />
              </van-cell>

              <van-cell :border="false" center is-link v-if="strShow">
                <span slot="title">街道：</span>
                <input slot="default" type="text" @click.stop="streetChoose" v-model="form.street" readonly placeholder="请选择街道" onfocus="blur();" />
              </van-cell>
            </van-cell-group>

            <div class="text_adderss">
              <input @focus="isFocus()" @blur="isBlur" placeholder="请输入详细地址" v-model="form.address" maxLength="100" />
            </div>
          </template>

          <div class="adderss_btn" v-if="!create" @click="appendAddress('update')">
            <button type="button">确认信息</button>
          </div>
        </div>
      </div>
    </template>
    <!-- 添加或者编辑地址 s-->
    <van-popup v-model="popAddAddress" :get-container="goodsStyle?'':'#appMain'" @closed="addRditClose" :close-on-click-overlay="false" class="pop-base-class" position="bottom" round style="background-color: #F5F5F5;" closeable>
      <div class="pop-base-title flex-a-c flex-j-sb">
        <div class="flex: 1;">{{ create ? $i18n.t('base.addAddress') : $i18n.t('base.editAddress') }}</div>
        <div @click="tapToParse" v-if="address_parse_open" class="f-12 themeColor" style="margin-right: 36px;">自动填写地址</div>
      </div>
      <div class="pop-base-content" style="padding: 0 0rem 5rem;">
        <van-cell-group inset>
          <van-field v-model="form.country_code" type="number" required :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.countryCode')"
          :label="$i18n.t('base.countryCode')+'：'" v-if="country_code"/>
          <van-field v-model="form.username" :label="$i18n.t('base.recipient')" :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.recipient')" />
          <van-field v-model="form.mobile" :label="$i18n.t('base.contactNumber')" :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.contactNumber')" />

          <template v-if="model.is_plugin == 1 && !region_hide">
            <van-field v-model="addressName" :label="$i18n.t('base.location')" :placeholder="$i18n.t('base.pleaseSelect') + $i18n.t('base.deliveryAddress')"
            is-link	readonly/>
            <van-field v-model="form.street" :label="$i18n.t('base.street')" :placeholder="$i18n.t('base.pleaseSelect') + $i18n.t('base.street')"
            is-link	v-if="strShow" readonly/>
            <van-field v-model="item.value" v-for="(item,index) in model.plugin_data" :key="index"
            :label="item.name" :placeholder="$i18n.t('base.pleaseEnter') + item.name" readonly/>
          </template>

          <template v-if="model.is_plugin != 1">

            <template v-if="!region_hide">
              <van-field v-model="addressName" :label="$i18n.t('base.location')" :placeholder="$i18n.t('base.pleaseSelect') + $i18n.t('base.deliveryAddress')"
              @click.stop="openAddress" readonly is-link	/>
              <van-field v-model="form.street" :label="$i18n.t('base.street')" :placeholder="$i18n.t('base.pleaseSelect') + $i18n.t('base.street')"
              @click.stop="streetChoose" is-link	v-if="strShow"/>
              <van-field v-model="form.address" rows="2" autosize :label="$i18n.t('base.addressDetails')"
                type="textarea" :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.addressDetails')" v-if="chainStore"/>
              <van-field v-model="form.pos.address" label="位置" placeholder="获取位置"
                @click.stop="posChoose" readonly v-if="chainStore" is-link	/>
            </template>
            <van-field v-model="form.address" rows="2" autosize :label="$i18n.t('base.addressDetails')"
                type="textarea" :placeholder="$i18n.t('base.pleaseEnter') + $i18n.t('base.addressDetails')" v-if="!chainStore"/>

            <template v-if="Object.keys(options).length != 0 && options.is_open_store_delivery && form.city && (options.selected == 3 || options.selected == 11)">
              <van-cell title="获取位置" :label="locationName" is-link @click.native="toGeolocation">
                <template #default>
                  {{ locationName ? '修改' : "定位中" }}
                </template>
              </van-cell>
            </template>
          </template>

        </van-cell-group>

        <van-cell-group inset style="margin-top: 8px;">
          <van-field name="switch" :label="$i18n.t('base.defaultAddress')" input-align="right">
            <template #input>
              <van-switch v-model="form.isDefault" disabled size="24" v-if="model.is_plugin == 1" active-color="var(--themeBaseColor)"/>
              <van-switch v-model="form.isDefault" :disabled='disableDefault' size="24" v-else active-color="var(--themeBaseColor)"/>
            </template>
          </van-field>
        </van-cell-group>

      </div>
      <div class="pop-base-bottom flex" >
        <van-button v-if="create" @click="appendAddress" round type="danger" block color="var(--themeBaseColor)" style="height: 40px;">{{$i18n.t('base.save')}}</van-button>
        <van-button v-else @click="appendAddress('update')" round type="danger" block color="var(--themeBaseColor)" style="height: 40px;">{{$i18n.t('base.save')}}</van-button>
      </div>
    </van-popup>
    <!-- 添加或者编辑地址 end-->

    <!-- 挂载节点问题，用vant再包一层 -->
    <template v-if="goodsStyle">
      <van-popup :get-container="goodsStyle?'#app':'#appMain'" v-model="addressShow" round position="bottom" :style="{ Height: '80vh' }">
        <!-- 省市区地址选择器 s -->
        <yd-cityselect style="height: 80%;z-index:1000000" v-model="addressShow" :callback="addressCallback" :items="district"></yd-cityselect>
        <!-- 省市区地址选择器 end -->
      </van-popup>
    </template>
    <yd-cityselect v-else style="height: 80%;z-index:1000000" v-model="addressShow" :callback="addressCallback" :items="district"></yd-cityselect>


    <!-- 街道选择器 s -->
    <van-popup :get-container="goodsStyle?'':'#appMain'" v-model="streetShow" class="pop-base-class" position="bottom" round style="background-color: #F5F5F5;" closeable>
      <div class="pop-base-title">选择街道</div>
      <div class="pop-base-content">
        <van-cell :border="false" center is-link v-for="(item, i) in districtVal" :key="i" @click.native="streetConfirm(item.areaname)" title-style="text-align:left">
          <span slot="title">{{ item.areaname }}</span>
        </van-cell>
      </div>
      <div class="pop-base-bottom flex" @click="streetShow = false">
        <van-button round type="danger" block color="var(--themeBaseColor)" style="height: 40px;">关闭</van-button>
      </div>
    </van-popup>
    <!-- 街道选择器 end -->

    <!-- 地图 s -->
    <location ref="locationR" v-model="showLocation" :center_path="center_path" :path_list="path_list" :local_city="local_city" v-on:confirm="confirmLocation"></location>
    <!-- 地图 end -->
    <addressParse :show="address_parse_show" @toPostMethod="toPostMethod" @address_parseClose="address_parseClose"></addressParse>
    <!-- 暂时保留，高德输入提示次数太少 -->
  </div>
</template>

<script>
import { Toast } from "vant";
import location from "./location";
import addressParse from "./address_parse.vue";
export default {
  model: {
    prop: "showAddress",
    event: "onEmit"
  },
  props: {
    //弹窗是否显示，默认不显示
    showAddress: {
      type: Boolean,
      default: false
    },
    options: {
      type: Object, //可接收配置项（对象类型！！！），增加可扩展性
      default: () => ({})
    },
    path_list: {
      type: Array
    },
    center_path: {
      type: Array
    },
    //详情使用的标识
    goodsStyle:{
      type:Boolean,
      default: true
    },
    disableDefault:{
      type:Boolean,
      default: false//是否禁止切换默认地址按钮
    },
  },
  data() {
    return {
      showLocation: false,
      popAddAddress: false,
      addressShow: false,
      streetShow: false,

      create: true, //新增与编辑标记
      form: {
        username: "",
        mobile: "",
        province: "",
        city: "",
        district: "",
        street: "",
        address: "",
        isDefault: false,
        country_code: '86'
      },
      is_region: 0,
      district: district, // 地址本地数据
      addressName: "", // 地址区域
      strShow: false, // 街道显示

      districtVal: "",
      addressData: [], //地址列表
      defaultAddress: [], //默认地址
      model:{},
      codeEdit:false,
      region_hide: 0,
      address_parse_open:0,
      address_parse_show:false,
      add_address:true,
      //连锁店标识 chainStore
      chainStore:false,
      chainStoreCityShow:false,

      finished: true
    };
  },
  watch: {
    // 如果 `showAddress` 发生改变，这个函数就会运行
    showAddress: function(newV, oldV) {
      if (newV) {
        this.addressData = [];
        this.page = 1;
        this.getAddress();
        this.getIsOpenAddress();// 关闭 地址栏
      }
    },
    popAddAddress:function(newV,oldV){
      if(newV){
        let yz_basic_info = JSON.parse(window.localStorage.getItem("yz_basic_info"));
        this.address_parse_open = yz_basic_info.plugin_setting.address_parse_open;
        this.country_code = yz_basic_info.home.system.country_code;
        if(this.chainStore){
          this.form.pos={};
        }
      }
    },
  },
  computed: {
    local_city() {
      return this.form.city;
    },
  },
  components: { location,addressParse },

  mounted() {},

  methods: {
    init(){
      //初始化
      this.popAddAddress = false;
      this.addressShow = false;
      this.streetShow = false;
      this.showLocation = false;
    },
    // 连锁店获取位置
    posChoose(){
      this.showLocation = true;
      this.$refs.locationR.chainStore = true;
    },
    toPostMethod(e){
      this.address_parseClose();
      this.form.address =  e.address;
      this.form.province = e.province;
      this.form.city = e.city;
      this.form.district = e.region;
      this.form.username = e.name;
      this.form.mobile = e.mobile;
      this.getStreet(e.region_id,e.street);
      this.addressName = `${e.province}${e.city}${e.region}`
    },
    tapToParse(){
      this.address_parse_show = true;
      this.popAddAddress = false;
    },
    address_parseClose(){
      this.address_parse_show = false;
      this.popAddAddress = true;
    },
    closedAddress() {
      this.$emit("onEmit", false);
    },
    openAddress() {
      this.addressShow = true;
    },
    // 获取收货地址
    getAddress() {
      $http.get("member.member-address.page", {page: this.page||1}, "获取中").then((response)=> {
        if (response.result === 1) {
          this.addressData = this.addressData.concat(response.data.data);
          this.total_page = response.data.last_page;
          this.page = response.data.current_page + 1;
          if(response.data.last_page == response.data.current_page) this.finished = false;
          let defaultAddress = response.data.data.filter(function(item) {
            return item.isdefault === 1;
          });
          this.defaultAddress = this.defaultAddress.concat(defaultAddress);
        } else {
          Toast(response.msg);
        }
      },
      function(response) {
        console.log(response);
      }
      );
    },
    selectAddress(item) {
      //选择了地址列表
      this.$emit("onEmit", false);
      this.$emit("confirm", item);
    },
    code_editAddress(item){
      //地址二维码编辑的回显
      if(item.district_id){
        this.getStreet(item.district_id);
      }
      this.model = item;
      this.form.address_id = item.id;
      this.form.username = item.username;
      this.form.mobile = item.mobile;
      this.form.province = item.province;
      this.form.city = item.city;
      this.form.district = item.district;
      this.form.address = item.address;
      this.form.street = item.street;
      this.form.isDefault = item.isdefault === 0 ? false : true;
      this.form.country_code = item.country_code;
      this.addressName = this.form.province + " " + this.form.city + " " + this.form.district;
      this.locationName = "";
      this.$forceUpdate();
      this.create = false;
      this.codeEdit = true;
    },
    // 设置地址
    editAddress(item) {
      this.getStreet(item.district_id);
      this.model = item;
      this.form.address_id = item.id;
      this.form.username = item.username;
      this.form.mobile = item.mobile;
      this.form.province = item.province;
      this.form.city = item.city;
      this.form.district = item.district;
      this.form.address = item.address;
      this.form.street = item.street;
      this.form.isDefault = item.isdefault === 0 ? false : true;
      this.form.country_code = item.country_code;
      this.addressName = this.form.province + " " + this.form.city + " " + this.form.district;
      this.locationName = "";
      if (Object.keys(this.options).length != 0 && this.options.is_open_store_delivery == true  && (this.options.selected == 3 || this.options.selected == 11)) {
        this.form.longitude = item.longitude || "";
        this.form.latitude = item.latitude || "";

        if (this.form.longitude) {
          this.locationName = "经度：" + this.form.longitude + "  纬度：" + this.form.latitude;
        }
      }
      if(this.chainStore){
        this.form.pos={};
        console.log(item.latitude)
        this.form.pos.latitude = item.latitude;
        this.form.pos.longitude = item.longitude;
        this.form.pos.address = item.position_address;
        console.log(this.form)
      }
      this.$forceUpdate();
      this.create = false;
      this.popAddAddress = true;
    },
    // 获取街道
    getStreet(param,key='') {
      this.district_id = param;
      $http
        .get("member.memberAddress.street", {
          district_id: param
        },'加载中')
        .then(response => {
          if (response.result === 1 && !this.fun.isTextEmpty(response.data)) {
            if (!this.fun.isTextEmpty(response.data) && response.data.length > 0) {
              this.districtVal = response.data;
              this.strShow = true;
              if(key){
                this.form.street = key;
              }
            } else {
              this.strShow = false;
            }
          } else {
            this.strShow = false;
          }
        })
        .catch(error => {
          this.strShow = false;
          console.log(error);
        });
    },
    streetChoose() {
      if (this.is_region == 1 && this.fun.isTextEmpty(this.addressName)) {
        this.$dialog.alert({ message: "请先选择所在地区" });
      } else {
        this.streetShow = true;
      }
    },
    // 关闭增加地址
    popAddressClose() {
      this.popAddAddress = false;
      this.$emit("onEmit", false);
    },
    toGeolocation() {
      this.getGeocoder();
    },
    getGeocoder() {
      let self = this;
      let geocoder = new AMap.Geocoder({
        // city 指定进行编码查询的城市，支持传入城市名、adcode 和 citycode
        city: self.local_city
      });
      geocoder.getLocation(this.addressName+this.form.address, (status, result)=> {
        if (status === 'complete'&&result.geocodes.length) {
          let lnglat = result.geocodes[0].location;
          let point = this.fun.bd_encrypt(lnglat.lng, lnglat.lat);
          this.form.longitude = point.lng;
          this.form.latitude = point.lat;
          this.locationName = "经度：" + this.form.longitude + "  纬度：" + this.form.latitude;
          this.$forceUpdate();
        }else{
          Toast('根据地址查询位置失败,请手动设置经纬度');
          this.showLocation = true;
        }
      });
    },
    confirmLocation(e) {
      if(this.chainStore){
        this.form.pos.latitude = e.point.lat;
        this.form.pos.longitude = e.point.lng;
        this.form.pos.address = e.address;
        this.$refs.locationR.chainStore = false;
        this.showLocation = false;
        return
      }
      if (e.point) {
        let point = this.fun.bd_encrypt(e.point.lng, e.point.lat);
        this.form.longitude = point.lng;
        this.form.latitude = point.lat;
        this.locationName = "经度：" + this.form.longitude + "  纬度：" + this.form.latitude;
      }
    },
    // 增加/修改地址
    appendAddress(str) {
      var that = this;
      if (this.country_code && this.fun.isTextEmpty(this.form.country_code)) {
        this.$dialog.alert({message:"请输入区号"});
        return;
      }
      if (this.fun.isTextEmpty(this.form.username)) {
        this.$dialog.alert({ message: "请输入收货人姓名" });
        return;
      }

      if (this.fun.isTextEmpty(this.form.mobile)) {
        this.$dialog.alert({ message: "请输入联系电话" });
        return;
      }
      // if (!/^[0-9]{1,}$/.test(this.form.mobile)) {
      //   this.$dialog.alert({ message: "请输入正确的联系电话" });
      //   return;
      // }
      if (!/^((1[3-9]\d{9})|(5[1-9]\d{7})|(6[0-9]\d{7})|(09\d{8}))$/.test(this.form.mobile)) {
        this.$dialog.alert({ message: "请输入正确的联系电话" });
        return;
      }

      if (this.is_region == 1 && this.fun.isTextEmpty(this.addressName)) {
        this.$dialog.alert({ message: "请选择所在区域" });
        return;
      }

      // if (this.is_region == 1 && this.strShow && this.fun.isTextEmpty(this.form.street)) {
      //   this.$dialog.alert({ message: "请选择所在街道" });
      //   return;
      // }

      if (this.fun.isTextEmpty(this.form.address)) {
        this.$dialog.alert({ message: "请输入详细地址" });
        return;
      }
      // 门店配送
      if (Object.keys(this.options).length != 0 && this.options.is_open_store_delivery == true && (this.options.selected == 3 || this.options.selected == 11)) {
        if (this.fun.isTextEmpty(this.form.longitude)) {
          this.$dialog.alert({ message: "请选择经纬度" });
          return;
        }
      }

      let json = {
        username: this.form.username,
        mobile: this.form.mobile,
        province: this.form.province == undefined ? "" : this.form.province,
        city: this.form.city,
        district: this.form.district,
        isdefault: this.form.isDefault ? 1 : 0,
        address_id: this.form.address_id,
        address: this.form.address,
      };
      if(this.country_code) json.country_code = this.form.country_code;
      if (this.strShow) {
        json.street = this.form.street;
      }
      if (Object.keys(this.options).length != 0 && this.options.is_open_store_delivery == true && (this.options.selected == 3 || this.options.selected == 11)) {
        json.longitude = this.form.longitude;
        json.latitude = this.form.latitude;
      }
      // 连锁店 新增传参
      if (this.chainStore){
        json.longitude = this.form.pos.longitude;
        json.latitude = this.form.pos.latitude;
        json.position_address = this.form.pos.address;
      }

      let api = "";
      if (str === "update") {
        api = "member.member-address.update";
      } else {
        api = "member.member-address.store";
      }

      $http.post(api, json, "").then(
        function(response) {
          if (response.result == 1) {
            that.popAddressClose();
            that.form.id = response.data.id;
            if(that.codeEdit || that.chainStore){
              //地址二维码回显 不清空初始化
              that.$emit("confirm", that.form); //触发父组件方法
              return
            }
            that.$dialog.alert({ message: response.msg });
            that.$emit("confirm", that.form); //触发父组件方法
            that.form = {
              username: "",
              mobile: "",
              province: "",
              city: "",
              district: "",
              street: "",
              address: "",
              isDefault: false
            };
            that.addressName = "";
          } else {
            that.$dialog.alert({ message: response.msg });
          }
        },
        function(response) {
          // error callback
        }
      );
    },
    // 关闭编辑和添加的弹窗
    addRditClose(){
      this.$emit('close')
    },
    // 地址回调
    addressCallback(obj) {
      this.form.street = "";
      this.districtVal = "";
      this.addressName = obj.itemName1 + " " + obj.itemName2 + " " + obj.itemName3;
      this.form.province = obj.itemName1;
      this.form.city = obj.itemName2;
      this.form.district = obj.itemName3;
      this.getStreet(obj.itemValue3);
    },
    streetConfirm(name) {
      this.form.street = name;
      this.streetShow = false;
    },
    isFocus() {
      this.isResize = true;
    },
    isBlur() {
      this.isResize = false;
    },
    // 跳转到新增地址
    addAddress() {
      // 新增地址 本地处理
      this.showAddAddress();
    },
    getIsOpenAddress() {
      $http
        .get("member.member-address.is-region",{},"加载中")
        .then(response => {
          if (response.result == 1) {
            let {is_region,region_hide} = response.data;
            this.is_region = is_region;
            this.region_hide = region_hide;//是否隐藏所在地区
          } else {
            console.log(response.msg);
          }
        })
        .catch(error => {
          console.log(error);
        });
    },
    // 显示增加地址
    showAddAddress() {
      let that = this;
      this.form = {
        username: "",
        mobile: "",
        province: "",
        city: "",
        district: "",
        street: "",
        address: "",
        isDefault: false,
        country_code: '86'
      };
      this.model = {};
      this.addressName = "";
      this.popAddAddress = true;
      this.create = true;
      this.locationName = "";
      // 如果地址列表里面没有默认的地址就把默认按钮设为true  优化任务#94289
      if(this.defaultAddress.length <= 0){this.form.isDefault = true}
      // 如果是详情使用的选择地址，地址为默认地址
      if(!this.goodsStyle){this.form.isDefault = true}
      if (this.is_open_store_delivery == true && (this.selected == 3 || this.selected== 11)) {
        that.form.longitude = "";
        that.form.latitude = "";
        that.locationName = "";
        if (that.$store.state.o2oLocation.point) {
          that.form.longitude = that.$store.state.o2oLocation.point ? that.$store.state.o2oLocation.point.lng : "";
          that.form.latitude = that.$store.state.o2oLocation.point ? that.$store.state.o2oLocation.point.lat : "";
          that.locationName = "经度：" + that.form.longitude + "  纬度：" + that.form.latitude;
        }
      }
    }
  }
};
</script>
<style>
.amap-sug-result {
  z-index: 9999;
}
</style>
<style lang="scss" rel="stylesheet/scss" scoped>
.margin-left-6 {
  margin-left: 0.375rem!important;
}
.margin-left-12 {
  margin-left: 0.75rem!important;
}
.pop-base-class {
  .pop-base-title {
    margin: 18px 12px 12px;
    font-size: 1rem;
    font-weight: bold;
    text-align: left;
  }
  .pop-base-content {
    min-height: 45vh;
    max-height: 55vh;
    overflow: scroll;
    padding: 0 0.75rem 5rem;
  }
  .pop-base-bottom {
    padding: 0.625rem 0.875rem;
    background: #ffffff;
  }
}
.box-base {
  border-radius: 0.5rem;
  padding: 0.75rem;
  background: #fff;
  margin-bottom: 0.625rem;
  text-align: left;
}


  input {
    border: none;
  }

  .blank-text {
    padding: 2rem 0;
    text-align: center;
    font-size: 16px;
    color: #666;
  }

  ::v-deep .yd-cityselect-active {
    z-index: 9999;
  }

  .award-list1 {
    .address-lists {
      max-height: 18rem;
      overflow: scroll;
      padding: 2.5rem 0.875rem 0;
      position: relative;

      .address-list-child {
        display: flex;
        align-items: center;
        padding: 0.875rem 0 0;

        .address-list-child-left {
          flex: 1;
          text-align: left;
          padding-right: 0.5rem;

          .address-namenick {
            display: flex;
            font-weight: 700;
          }

          .isdefault {
            margin-left: 5px;
            flex: 0 0 30px;
            color: #f14e4e;
          }
        }

        .address-list-child-right {
          width: 3.75rem;
          height: 1.75rem;
          line-height: 1.75rem;

          /* background-color: #f14e4e; */

          /* border-radius: 0.375rem; */
          color: #f14e4e;
        }
      }
    }

    .confirm-address-btn {
      position: absolute;
      bottom: 1rem;
      left: 50%;
      transform: translateX(-50%);
      width: 21.625rem;
      height: 2.75rem;
      background-color: #f14e4e;
      border-radius: 1.375rem;
      font-weight: 700;
      font-size: 16px;
      color: #fff;
      line-height: 2.75rem;
    }
  }

  .m-dialog {
    width: 100%;
    z-index: 100;
  }

  .popHeader,
  .DYFpopHeader {
    position: relative;
    width: 100%;
    height: 2.5rem;
    background: white;
    display: flex;
    font-size: 16px;
    text-align: center;

    p {
      font-weight: bold;
      flex: 1;
      align-self: center;
    }

    i {
      padding: 0.5rem;
      align-self: center;
      flex: 0 0 1.5rem;
    }
  }

  .DYFpopHeader {
    position: fixed;
    top: 0;
    z-index: 9;
  }
  // 新css
  .address_a,
  .address_b {
    background-color: #fff;
    padding-left: 14px;

    li {
      height: 3.125rem;
      line-height: 3.125rem;
      padding-right: 14px;

      /* border-bottom:solid 0.0625rem #ebebeb; */
      display: flex;
      align-items: center;
      font-size: 16px;
    }

    li:last-child {
      border: none;
    }
  }

  .set-address {
    .van-cell {
      padding: 10px 12px;

      .van-cell__title {
        flex: none;
        color: #555;
        text-align: left;
      }

      .van-cell__value {
        input {
          color: #555;
          width: 100%;
        }
      }
    }

    ::v-deep .van-cell:active {
      background-color: #fff !important;
    }
  }

  .address_a span {
    white-space: nowrap;
  }

  .address_b {
    margin-bottom: 0.625rem;

    li {
      justify-content: space-between;
    }
  }

  .text_adderss {
    background-color: #fff;

    input {
      text-wrap: unset;
      padding: 0.625rem 0.875rem;
      font-size: 14px;
      line-height: 1.5rem;
      width: 100%;
      min-height: 3.25rem;
    }
  }

  .adderss_btn {
    margin: 1.25rem auto;

    button {
      width: 18.75rem;
      height: 2.8125rem;
      border-radius: 0.3125rem;
      background: #f15353;
      color: #fff;
      padding: 0;
      border: none;

      i {
        font-size: 1.125rem;
        margin-right: 0.375rem;
      }
    }
  }
  .adderss_btnChain{
    button{
      background: var(--themeBaseColor);
    }
  }

  .address_addnav {
    z-index: 10;
    position: fixed;
    bottom: 0;
    width: 100%;
    padding: 0 3% 0 6% !important;
    left: 0;
    background: #f15353 !important;
    color: #fff !important;
    text-align: center;
    height: 2.8125rem !important;
    line-height: 2.8125rem !important;
  }
.autoAddressTxt{
  line-height: 2.5rem;
  font-size: 13px;
  color: #EF5452;
  position: absolute;
  right: 0.25rem;
  top: 0;
}
</style>
